package vuelta.general.stage.zoom;


import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import vuelta.general.util.Commons;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.os.Bundle;

public class PlanimetriaZoomActivity extends ImageRootActivity {
	private Bitmap mBitmap;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	protected Bitmap getBitmapImage(Options options) {
		JSONArray jsonArray = Commons.getInstance().getTappeArrayJson();
		int stageNumber = Commons.getInstance().getSelectItemPosition();
		JSONObject jsonObject = null;

		try {
			jsonObject = (JSONObject) jsonArray.get(stageNumber - 1);
		} catch (JSONException e1) {
			e1.printStackTrace();
		}

		String planimetriaFile = "";
		try {
			planimetriaFile = jsonObject.getString("planimetria");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		int nameResourceID = getResources()
				.getIdentifier(planimetriaFile, "drawable", getApplicationInfo().packageName);
		mBitmap = BitmapFactory.decodeResource(getResources(), nameResourceID, options);
		return mBitmap;
	}

	@Override
	protected void recycleBitmap() {
		mBitmap.recycle();
	}

}
